
public class ListOfAtoms {
        
        private int size;
        private int nbOfAtoms;
        private Atom [] atom;  
        
        public ListOfAtoms (int n) {         
                
                nbOfAtoms = 0;
                size = n;
                atom =  new Atom[n];
                }

        public boolean full () {
                return nbOfAtoms == size;
                }
                public boolean empty () {
                return nbOfAtoms == 0;
                }
                
                public Atom retrieve ( int nbtheAtoms) {
                        return atom[nbtheAtoms];
                }
                
                public boolean addAtom (String name) {// I changed the parameter because in the parser I need to add Atom with specific name.
                        
                        if (getNbOfAtoms() < getSize()) {
                                atom[getNbOfAtoms()] = new Atom(name);
                                nbOfAtoms++;
                                        return true;
                        }
                        else
                                return false;
                }
                
                

                public boolean removeAtom (String nameOfType) {
                 
                                for (int i =0 ; i < size; i++) {
                                        if (atom[i].getName().equals(nameOfType) ){
                                                
                                                for(int p = i+1 ; p < nbOfAtoms ; p++){
                                                        atom[p-1] = atom[p];
                                                }
                                                nbOfAtoms--;    
                                                return true ;
                                        }
                                        
                                }
                                return false ;
                }
                
                public int findAtomByName(String nameOfAtom){
                        for(int i = 0 ; i < getNbOfAtoms() ; i++){
                                if(atom[i].getName().equals(nameOfAtom)){
                                         
                                        return i ;
                                }
                        }
                        return -1 ;
                }
                
               
                
   public void display(){
	    System.out.println("=========================================");
        for(int i=0 ; i<getNbOfAtoms() ; i++){
              atom[i].display();
              System.out.println("=========================================");
        }
  }
                

                public int getSize() {
                        return size;
                }

                public int getNbOfAtoms() {
                        return nbOfAtoms;
                }

                public Atom[] getAtom() {
                        return atom;
                }

                public void setSize(int size) {
                	if (size > nbOfAtoms )
                        this.size = size;
         else System.out.println(" you write size less than number of element in array , please rewrite the size ");
                
                }
                public void setAtom(Atom[] atom) {
                        this.atom = atom;
                }
}